Runat = {Server:'server', Client:'client'};

Engine = {};
Engine.processEventCallClient = function(http)
{   
    $.each(http, function(i,item){
          Engine.renderCommand(item);
    });
};


//pegando os controles retornados e rederizando na pagina
Engine.renderControlFromParser = function(tControl)
{
	if(!tControl.id) return;
	var control = document.getElementById(tControl.id);
	if(control)
	{
		control.innerHTML = tControl.innerHTML;
	}	
};

Engine.processControls = function (tag)
{
	if(tag)
	{		
		tag = tag.childNodes;		
		for(var i=0; i<tag.length; i++)
		{
			this.renderControlFromParser(tag.item(i));
		}
	}
};

Engine.processEvent = function (tag)
{
	if(tag)
	{
		tag = tag.childNodes;		
		for(var i=0; i<tag.length; i++)
		{
			this.renderEvent(tag.item(i));
		}
	}	
}

Engine.renderEvent = function(tControl)
{
	if(!tControl.id) return;

	var id = 	tControl.getAttribute("valueid");
	var func = 	tControl.getAttribute("funct");
	var module = 	tControl.getAttribute("module");
	var runat = 	tControl.getAttribute("runat");
	var type = 	tControl.getAttribute("type");
	
	var controle = document.getElementById(id);
	if(controle){
		Events.addEvent(controle, type, module, func, runat);
	}
};

Engine.renderCommand = function(tControl)
{
	if(!tControl.id) return;
	switch(tControl.type)
	{
		case "TextInput":	Control.TextBox(tControl);	break;
        case "Tag":	Control.Tag(tControl);	break;
		case "TextArea":Control.TextArea(tControl);	break;

	}
};


